package com.haizhi.workstation.util;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class UserContext {

    public static HttpSession getSession(){
        return getRequest().getSession();
    }
    /*public static void setCurrentUser(LoginInfo loginInfo){
        getSession().setAttribute(USER_IN_SESSION,loginInfo);
    }

    public static LoginInfo getCurrentUser(){
        return (LoginInfo) getSession().getAttribute(USER_IN_SESSION);
    }*/


    public static HttpServletRequest getRequest(){
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        return ((ServletRequestAttributes)(RequestContextHolder.getRequestAttributes())).getRequest();
    }

}
